#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>

int main(int argc, char *argv[])
{
    cv::Mat mat(400, 300, cv::CV_8UC3);
    int es = mat.elemSize();
    int size = mat.cols * mat.rows * es;
    for (int i = 0; i < size; i += es)
    {
        mat.data[i] = 200;
        mat.data[i + 1] = 100;
        mat.data[i + 2] = 50;
    }
    cv::namedWindow("mat");
    cv::imshow("mat",mat);
    cv::waitKey(0);
    return 0;
}
